package com.eight.cloud.openfeign.message.factory;

import com.eight.cloud.openfeign.message.api.MessageClient;
import com.eight.cloud.openfeign.message.model.MqMessage;
import com.eight.cloud.openfeign.message.model.SocketMessage;
import com.eight.cloud.core.global.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @ClassName: MessageFallbackFactory
 * @Author: TXC
 * @Date: 2024-10-11 14:11
 **/
@Component
@Slf4j
public class MessageFallbackFactory implements FallbackFactory<MessageClient> {
    @Override
    public MessageClient create(Throwable cause) {
        return new MessageClient() {
            @Override
            public Result<String> sendWebSocketMessage(SocketMessage<?> socketMessage) {
                return Result.fail();
            }

            @Override
            public Result<String> sendRabbitMessage(MqMessage<?> mqMessage) {
                return Result.fail();
            }
        };
    }
}
